"""
组织架构页面
"""

from selenium.webdriver.common.by import By
from pages.base_page import BasePage

class TissuePage(BasePage):
    url = '/crm/index.php?m=user'
    post_add_locator = (By.ID, 'add_role')
    post_name_locator = (By.XPATH, '//*[@id="role_add"]/div[1]/div/input')
    post_ok_locator = (By.XPATH, '/html/body/div[9]/div[3]/div/button[1]')
    post_add_ok_locator = tissue_add_ok_locator = (By.XPATH,'/html/body/div[5]/div[2]')
    add_department_locator = (By.ID, 'add_department')
    department_content_locator = (By.XPATH, '//*[@id="department_add"]/div[3]/div/textarea')
    department_name_locator = (By.XPATH, '//*[@id="name"]')
    btn_OK_locator = (By.XPATH, '/html/body/div[8]/div[3]/div/button[1]/span')
    post_locator = (By.ID, 'ui-id-6')
    tissue_locator = (By.ID, 'ui-id-5')
    btn_on_locator = (By.XPATH,'/html/body/div[8]/div[3]/div/button[2]')


    #断言岗位位子
    def post_where(self):
        return self.driver.find_element(*self.post_locator).text

    #新增岗位
    def add_post(self):
        self.driver.find_element(*self.post_add_locator).click()

    #新增岗位，用户名输入
    def input_name(self,post_name):
        self.driver.find_element(*self.post_name_locator).send_keys(post_name)

    #新增岗位保存
    def post_ok(self):
      self.driver.find_element(*self.post_ok_locator).click()

    #断言添加岗位成功
    def post_add_ok(self):
        return self.driver.find_element(*self.post_add_ok_locator).text

    #断言岗位位子
    def tissue_where(self):
        return self.driver.find_element(*self.tissue_locator).text

    #新增部门
    def add_tissue(self):
        self.driver.find_element(*self.add_department_locator).click()

    #新增部门取消
    def add_tissue_no(self):
        self.driver.find_element(*self.btn_on_locator).click()

    #新增部门,输入描述
    def input_tissue_content(self,content):
        self.driver.find_element(*self.department_content_locator).send_keys(content)

    #新增部门,输入部门名
    def input_tissue_name(self,department):
        self.driver.find_element(*self.department_name_locator).send_keys(department)


    #新增部门,保存
    def tissue_ok(self):
        self.driver.find_element(*self.btn_OK_locator).click()

    #断言添加部门成功
    def tissue_add_ok(self):
        return self.driver.find_element(*self.tissue_add_ok_locator).text




